package com.core.pagehelper.serviceImpl;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.core.pagehelper.dao.UserInforMapper;
import com.core.pagehelper.entity.PageBean;
import com.core.pagehelper.entity.UserInfor;
import com.core.pagehelper.service.PageHelperShowService;
import com.github.pagehelper.PageHelper;

@Service("pageHelperShowService")
public class PageHelperShowServiceImpl implements PageHelperShowService{
	private static final Logger logger = Logger.getLogger(PageHelperShowServiceImpl.class);
	@Resource
	private UserInforMapper userinforMapper;

	public PageBean<UserInfor> showPage(HttpServletRequest request){
		int pageNum = Integer.parseInt(request.getParameter("pageNum"));
		int pageSize = Integer.parseInt(request.getParameter("pageSize"));
		logger.info("--pageNum:"+pageNum+"     pageSize:"+pageSize);
		PageHelper.startPage(pageNum, pageSize);
		List<UserInfor> list = userinforMapper.selectAll();
		return new PageBean<UserInfor>(list);
	}

	public int batchInserts(List<UserInfor> list) {
		int result = userinforMapper.insertMore(list);
		logger.info("---result--"+result);
		return result;
	}

}
